//
//  ZTXYunDanProjectListCell.m
//  NtoccDriverNew
//
//  Created by 张天兴 on 2023/10/19.
//  Copyright © 2023 GCY. All rights reserved.
//

#import "ZTXYunDanProjectListCell.h"

@implementation ZTXYunDanProjectListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _branchNameLabel.textColor = Dark_TextColor;
    _oddNumbersLabel.textColor = Dark_TextColor;
    _oddNumbersLabel.adjustsFontSizeToFitWidth = YES;
    _zhuangAddressLabel.textColor = Dark_TextColor;
    _xieAddressLabel.textColor = Dark_TextColor;
    _nameLabel.textColor = Dark_TextColor;
    _carInfoLabel.textColor = Light_TextColor;
    _loadDetailAddressLab.textColor = Dark_TextColor;
    _unloadDetailAddressLab.textColor = Dark_TextColor;
    _jieDanButton.layer.masksToBounds = YES;
    _jieDanButton.layer.cornerRadius = 10;
    _branchNameLabel.font = font(15);
    _zhuangAddressLabel.font = font(14);
    _zhuangAddressLabel.numberOfLines = 2;
    _zhuangAddressLabel.adjustsFontSizeToFitWidth = YES;
    _xieAddressLabel.font = font(14);
    _xieAddressLabel.numberOfLines = 2;
    _xieAddressLabel.adjustsFontSizeToFitWidth = YES;
    _nameLabel.font = font(13);
    _carInfoLabel.font = font(11);
    _carInfoLabel.numberOfLines = 2;
    _loadDetailAddressLab.font = font(12);
    _unloadDetailAddressLab.font = font(12);
}
- (void)setSupplyModel:(YunDanCenterModel *)supplyModel {
    
    _supplyModel = supplyModel;
    if(supplyModel.createdByName.length == 0) {
        _branchNameLabel.text = @"--";

    }else{
        _branchNameLabel.text = CJStringWithFormat(@"发货企业:%@",supplyModel.createdByName);
    }
    _oddNumbersLabel.text = [NSString stringWithFormat:@"货源单号：%@",_supplyModel.mainOrderNumber];
    _zhuangAddressLabel.text = supplyModel.shipperAddress;
    _loadDetailAddressLab.text = supplyModel.shipperDetailAddress;
    _xieAddressLabel.text = supplyModel.consigneeAddress;
    _unloadDetailAddressLab.text = supplyModel.consigneeDetailAddress;
    _nameLabel.text = CJStringWithFormat(@"发货人:%@",supplyModel.shipperName);
    _juliLabel.text = [NSString stringWithFormat:@"距离：%.2fkm",_supplyModel.distance];
    NSString *notReceivedCount = @"";
    if (supplyModel.notReceivedCount == 0) {
        notReceivedCount = @"不限车";
    } else {
        notReceivedCount = CJStringWithFormat(@"%ld车",(long)supplyModel.notReceivedCount);
    }
//
    NSString *lastWeight = @"";

    if ([DCSpeedy isPureInt:supplyModel.lastWeight]) {
        lastWeight = supplyModel.lastWeight;
    } else {
        lastWeight = CJStringWithFormat(@"%.3f", [supplyModel.lastWeight floatValue]);
    }
//
    if (supplyModel.isQuote == 1) {
        //允许报价，0-不允许，1-允许
        _carInfoLabel.text = CJStringWithFormat(@"%@ %@ %@%@ %@", supplyModel.coalTypeName, notReceivedCount, lastWeight, supplyModel.coalUnitName, [NSString nullToString:supplyModel.pushVehicleUse]);
    } else {
        _carInfoLabel.text = CJStringWithFormat(@"%@ %.2f%@ %@ %@%@ %@", supplyModel.coalTypeName, supplyModel.realPrice, supplyModel.isTrunkName, notReceivedCount, lastWeight, supplyModel.coalUnitName, [NSString nullToString:supplyModel.pushVehicleUse]);
    }
    
    [_headImageView setImageWithURL:[NSURL URLWithString:_supplyModel.coalName] placeholder:image(@"gcy_img_main_head")];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)telButton:(id)sender {
    CALL_PHONE(_supplyModel.shipmentPhone);
}

@end
